import 'package:flutter/services.dart';
import 'package:enterprise_v8/app/core/core.dart';
import 'package:enterprise_v8/modules/home/controller.dart';

class HomePage extends StatelessWidget {
  HomePage({super.key});

  final controller = Get.put(HomeController());

  @override
  Widget build(BuildContext context) {
    return PopScope(
      canPop: false,
      onPopInvoked: (bool isPop) {
        final bool pop = controller.exitReminder();
        if (pop) {
          SystemChannels.platform.invokeMethod('SystemNavigator.pop');
        }
      },
      child: GetBuilder(builder: (HomeController controller) {
        return Scaffold(
            backgroundColor: AppColors.bg_color_grey,
            body: IndexedStack(
              index: controller.index.value,
              children: controller.myTabs,
            ),

            bottomNavigationBar: BottomNavigationBar(
              type: BottomNavigationBarType.fixed,
              currentIndex: controller.index.value,
              onTap: (index) {
                controller.index.value = index;
                controller.update();
              },
              items: [
                BottomNavigationBarItem(
                  icon: Icon(
                      controller.tabIcon[0],
                    ),
                  label: controller.tabName[0],
                ),
                BottomNavigationBarItem(
                  icon: Badge(
                    child: Icon(
                      controller.tabIcon[1],
                    ),
                  ),
                  label: controller.tabName[1],
                ),
                BottomNavigationBarItem(
                  icon:  Icon(
                        controller.tabIcon[2],
                      ),
                  label: controller.tabName[2],
                ),
                BottomNavigationBarItem(
                  icon: Icon(
                      controller.tabIcon[3],
                    ),
                  label: controller.tabName[3],
                ),
              ],
            ),

        );
      }),
    );
  }
}
